package framework

import (
	"../action"
	"../global"
)

func SetRouter() {
	//管理员路由
	AdminAction := new(action.Admin)

	//测试，获取token
	app.GET("/admin/token", AdminAction.Token)
	app.POST("/admin/register", AdminAction.Register)
	app.POST("/admin/login", AdminAction.Login)

	//后台路由除去登录注册，全部需要经过token中间件
	AdminRouter := app.Group("/admin/admin", CheckToken(global.TokenToption.Key, global.TokenToption.Method, global.TokenToption.ParamName))
	AdminRouter.GET("/index", AdminAction.Index)
	AdminRouter.GET("/show/:admin_id", AdminAction.Show)
	AdminRouter.PUT("/edit/:admin_id", AdminAction.Edit)
	AdminRouter.DELETE("/delete/:admin_ids", AdminAction.Delete)

	//用户路由
	UserRouter := app.Group("/admin/user", CheckToken(global.TokenToption.Key, global.TokenToption.Method, global.TokenToption.ParamName))
	UserAction := new(action.User)
	UserRouter.GET("/index", UserAction.Index)
	UserRouter.GET("/show/:user_id", UserAction.Show)
	UserRouter.PUT("/edit/:user_id", UserAction.Edit)
	UserRouter.DELETE("/delete/:user_ids", UserAction.Delete)

	//订单路由
	OrderRouter := app.Group("/admin/order", CheckToken(global.TokenToption.Key, global.TokenToption.Method, global.TokenToption.ParamName))
	OrderAction := new(action.Order)
	OrderRouter.GET("/now", OrderAction.NowOrderIndex)
	//历史订单
	OrderRouter.GET("/history", OrderAction.HistoryOrderIndex)
	OrderRouter.DELETE("/history/delete/:order_ids", OrderAction.DeleteHistoryOrder)
	//充值订单
	OrderRouter.GET("/recharge", OrderAction.RechargeOrderIndex)
	OrderRouter.DELETE("/recharge/delete/:order_ids", OrderAction.DeleteRechargeOrder)

	//提现订单
	OrderRouter.GET("/withdraw", OrderAction.WithdrawOrderIndex)
	OrderRouter.GET("/withdraw/show/:order_id", OrderAction.WithdrawOrderShow)
	OrderRouter.PUT("/withdraw/edit/:order_id", OrderAction.WithdrawOrderEdit)
	OrderRouter.DELETE("/withdraw/delete/:order_ids", OrderAction.DeleteWithdrawOrder)
	OrderRouter.GET("/withdraw/operate/:order_id", OrderAction.WithdrawOrderOperate)
	OrderRouter.GET("/withdraw/query/:order_id", OrderAction.WithdrawStatusQuery)
	OrderRouter.GET("/withdraw/reset/:order_id", OrderAction.WithdrawStatusReset)

	//支付渠道路由
	ChannelRouter := app.Group("/admin/channel", CheckToken(global.TokenToption.Key, global.TokenToption.Method, global.TokenToption.ParamName))
	ChannelAction := new(action.Channel)
	ChannelRouter.GET("/index", ChannelAction.Index)
	ChannelRouter.POST("/create", ChannelAction.Create)
	ChannelRouter.GET("/show/:channel_id", ChannelAction.Show)
	ChannelRouter.PUT("/edit/:channel_id", ChannelAction.Edit)
	ChannelRouter.DELETE("/delete/:channel_ids", ChannelAction.Delete)

	//经纪人结算记录路由
	BrokerageRouter := app.Group("/admin/brokerage", CheckToken(global.TokenToption.Key, global.TokenToption.Method, global.TokenToption.ParamName))
	BrokerageAction := new(action.Brokerage)
	BrokerageRouter.GET("/index", BrokerageAction.Index)
	BrokerageRouter.POST("/create", BrokerageAction.Create)
	BrokerageRouter.GET("/show/:brokerage_id", BrokerageAction.Show)
	BrokerageRouter.PUT("/edit/:brokerage_id", BrokerageAction.Edit)
	BrokerageRouter.DELETE("/delete/:brokerage_ids", BrokerageAction.Delete)
}
